package larpplanner.database;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;


@DBTable("quest")
public class Quest implements DBObject{
	
	public static final String ID_COL       = "quest_id";
	public static final String NAME_COL     = "quest_name";
	public static final String LOCATION_COL = "location";
	public static final String DATE_COL     = "quest_date";
	public static final String DETAILS_COL  = "details";
	
    @DBCol(ID_COL)
	protected long id;
	
    @DBCol(NAME_COL)
    protected String name;
	
    @DBCol(LOCATION_COL)
    protected String location;
	
    @DBCol(DATE_COL)
    protected Timestamp date;
	
    @DBCol(DETAILS_COL)
    protected String details;
	
    @DBMapRelation(table="player_quest_char", cols={Player.ID_COL,FicCharacter.ID_COL})
    protected Map<Player, FicCharacter> participants = new HashMap<Player, FicCharacter>();
	
	
	public Quest() {}
	
	public Quest(String name, String location, Timestamp date, String details) {
		this.name = name;
		this.location = location;
		this.date = date;
		this.details = details;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public String getLocation() {
		return location;
	}

	public void setDate(Timestamp date) {
		this.date = date;
	}

	public Timestamp getDate() {
		return date;
	}

	public void setDetails(String details) {
		this.details = details;
	}

	public String getDetails() {
		return details;
	}
    
    public Map<Player, FicCharacter> getParticipants() {
        return participants;
    }
    
    public void setParticipants(Map<Player, FicCharacter> participants) {
        this.participants = participants;
    }
	public String toString() {
		return name;
	}
	
    public String getFullRepresentitiveString() {
        return "" + (id == 0 ? "?" : id) + " " + name + " " + location + " "
                + date + " " + details + " ~ " + participants;
    }
	  
}
